package com.qm.console.controller.rest;

import com.qm.console.controller.dto.BaseRsp;
import com.qm.console.pubdef.dto.notice.NoticeUpdateAdminDTO;
import com.qm.console.pubdef.dto.notice.RecommendUpdateAdminDTO;
import com.qm.console.service.notice.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("notice")
public class NoticeController {
    @Autowired
    private NoticeService NoticeService;

//    @GetMapping("/list")
//    public BaseRsp listNoticeAdmin(@RequestParam(value = "limit", required = false, defaultValue = "20") String limit,
//                                     @RequestParam(value = "page", required = false, defaultValue = "1") String page){
//        Map<String, String> paramMap = new HashMap<>();
//        paramMap.put("pageSize", limit);
//        paramMap.put("pageNum", page);
//        return NoticeService.listNoticeAdmin(paramMap);
//    }
//
//    @PostMapping("/update")
//    public BaseRsp updateNoticeAdmin(@RequestBody NoticeUpdateAdminDTO updateDTO){
//        return NoticeService.updateNoticeAdmin(updateDTO);
//    }

    @DeleteMapping("/delete")
    public BaseRsp deleteNoticeAdmin(@RequestBody String noticeId){
        return NoticeService.deleteNoticeAdmin(noticeId);
    }

    @GetMapping("/recommend/list")
    public BaseRsp listRecommendAdmin(@RequestParam(value = "limit", required = false, defaultValue = "20") String limit,
                                      @RequestParam(value = "page", required = false, defaultValue = "1") String page,
                                      @RequestParam(value = "userId", required = false) String userId
                                      ){
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("pageSize", limit);
        paramMap.put("pageNum", page);
        if(userId!=null){
            paramMap.put("userId", userId);
        }
        return NoticeService.listRecommendAdmin(paramMap);
    }

    @PostMapping("/recommend/add")
    public BaseRsp addRecommendAdmin(@RequestBody RecommendUpdateAdminDTO updateDTO){
        return NoticeService.addRecommendAdmin(updateDTO);
    }

    @DeleteMapping("/recommend/delete")
    public BaseRsp deleteRecommendAdmin(@RequestBody String userId){
        return NoticeService.deleteRecommendAdmin(userId);
    }



}
